﻿// Fill out your copyright notice in the Description page of Project Settings.


#include "BTTaskNode/TaskSetAISpeed.h"

#include "AIController.h"
#include "Character/EnemyCharacter.h"
#include "GameFramework/CharacterMovementComponent.h"

UTaskSetAISpeed::UTaskSetAISpeed()
{
	NodeName = FString("SetAISpeed");
}

EBTNodeResult::Type UTaskSetAISpeed::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
	AAIController* AaiController = OwnerComp.GetAIOwner();
	ABaseCharacter* BaseCharacter = Cast<ABaseCharacter>(AaiController->GetPawn());
	if (AaiController == nullptr || BaseCharacter == nullptr)
	{
		return EBTNodeResult::Failed;
	}
	BaseCharacter->GetCharacterMovement()->MaxWalkSpeed = Speed;
	return EBTNodeResult::Succeeded;
}

uint16 UTaskSetAISpeed::GetSpecialMemorySize() const
{
	return Super::GetSpecialMemorySize();
}
